<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .a1 {
        position: relative;
        width: 200px;
        height: 300px;
        border: 1px solid red;
        margin: auto;
        background: url(./q1.jpg);
        overflow: hidden;
    }
.a1>.a2{
    position: absolute;
    width: 100%;
    height: 120px;
    background: rgba(0, 0,0, 0.5);
    bottom: 0px;
    /* 在布局中直接用bottom */
    opacity: 0;
    /* 透明度 */
    margin-bottom: -120px;

    
}
.a2>h1{
    font-size: 20px;
    color:white;
    margin-left: 10px;
}
.a2>p{
    color: white;
    margin-left: 10px;
}
.a1:hover .a2{ 
margin-bottom: 0px;
opacity: 0.5;
/* 透明度 */
transition: 2s;
/* 设置动画动画时间 */
}
</style>

<body>
    <div class="a1">
        <div class="a2">
<h1>文字标题</h1>
<p>图片文字说明，图片文字说明图片文字说明</p>
        </div>
    </div>
</body>

</html>